import { _decorator, Node } from 'cc';
import { ecs } from 'db://app-game/libs/ecs/ECS';
import { CCComp } from 'db://app-game/module/common/CCComp';
import { Level } from '../Level';

const { ccclass, property } = _decorator;

/** 关卡视图组件 */
@ccclass('LevelViewComp')
@ecs.register('LevelView', false)
export class LevelViewComp extends CCComp {
  /** 关卡实例 */
  level!: Level;
  /** ui画布节点 */
  uiCanvasNode!: Node;

  protected onLoad(): void {
    this.level = this.ent as Level;
    this.uiCanvasNode = this.node.getChildByName('ui');
  }

  /** 加载ui节点 */
  loadUINode(uiNode: Node) {
    this.uiCanvasNode.addChild(uiNode);
  }

  reset(ent: ecs.Entity): void {
    this.node.destroy();
  }
}
